const roles = {
    free: {
        permissions: ['view_home', 'view_treasureBox', 'view_market', 'view_price', 'view_supplier', 'view_leads', 'view_invite','view_personal_center']
    },
    base: {
        permissions: ['view_home', 'view_treasureBox', 'view_market', 'view_price', 'view_supplier', 'view_leads', 'view_invite','view_personal_center']
    },
    high: {
        permissions: ['view_home', 'view_treasureBox', 'view_market', 'view_price', 'view_supplier', 'view_leads', 'view_invite','view_personal_center']
    }
};

export function hasPermission(vip_level, permission) {
    const roleMap = {
        0: 'free',
        10: 'base',
        20: 'high'
    };

    const userRole = roleMap[vip_level];
    if (!userRole) return false;

    const permissions = roles[userRole]?.permissions || [];
    return permissions.includes(permission);
}